package com.msg.chestionar.entities;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import com.msg.chestionar.to.UtilizatorTO;

@NamedQueries( { @NamedQuery(name = "UtilizatorE.findByNameAndPassword", query = "SELECT u FROM UtilizatorE u WHERE u.username = :name AND u.parola = :parola") })
@Entity
@Table(name = "T_USER")
public class UtilizatorE {

	@Id
	@GeneratedValue
	private Long id;

	@Column
	private String username;

	@Column
	private String parola;

	@Column
	private int tip;

	@Column
	private int activ;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getParola() {
		return parola;
	}

	public void setParola(String parola) {
		this.parola = parola;
	}

	public int getTip() {
		return tip;
	}

	public void setTip(int tip) {
		this.tip = tip;
	}

	public int getActiv() {
		return activ;
	}
 
	public void setActiv(int activ) {
		this.activ = activ;
	}

	public UtilizatorTO getUtilizatorTO() {
		UtilizatorTO user = new UtilizatorTO();
		user.setId(this.id);
		user.setUsername(this.username);
		user.setParola(this.parola);
		user.setTip(this.tip);
		user.setActiv(this.activ == 1);
		return user;
	}

}
